package com.qf.service.caiwu_service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.bean.Debt;
import com.qf.dao.caiwu_dao.DebtMapper;
import com.qf.service.caiwu_service.DebtService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 2019/12/10 0010
 * Author->DT
 * sassspringboot
 * 行到水穷处 坐看云起时
 * 模块：
 */
@Service
public class DebtServiceImpl implements DebtService {
    @Resource
    private DebtMapper debtMapper;
    @Override
    public PageInfo<Debt> findDebtListByLimit(Map map) {
        //开启分页
        PageHelper.startPage((int)map.get("index"),(int)map.get("page"));
        //查询欠款信息列表
        List<Debt> list=debtMapper.findDeptList(map);
        //封装PageInfo
        PageInfo<Debt> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public Debt selectByPrimaryKey(Integer did) {
        return debtMapper.selectByPrimaryKey(did);
    }

    //欠款表中欠款金额减去收款金额
    @Override
    public int subtractOwe(double refund,Integer did) {
        return debtMapper.subtractOwe(refund,did);
    }

    @Override
    public int updateByPrimaryKeySelective(Debt record) {
        return debtMapper.updateByPrimaryKeySelective(record);
    }
}
